//复数乘法: https://www.nowcoder.com/exam/test/90862939/detail?pid=20725660
/*
复数乘法： (a + bi)*(c + di) = ac + bd*i^2 + cbi + adi
其中i^2 = -1
*/
#include <iostream>
#include <string>
using namespace std;
// 字符串转整形
int stringtoInt(string s) {
    int num = 0;
    int flag = 1;
    for (int i = 0; i < s.size(); i++) 
    {
        // 如果有负号，说明是负数
        if (s[i] == '-') 
        {
            flag = -1;
        }
        // 只利用数字字符，i不使用
        else if (s[i] >= '0' && s[i] <= '9')
        {
            num = num * 10 + (s[i] - '0');
        }
    }
    return num * flag;
}
int main() {
    string s1, s2;
    while (cin >> s1 >> s2) {
        // 截取整数部分
        string s1First = s1.substr(0, s1.find('+'));
        string s2First = s2.substr(0, s2.find('+'));
        // 截取复数部分
        // 复数1
        string s1Second = s1.substr(s1.find('+') + 1);
        // 复数2
        string s2Second = s2.substr(s2.find('+') + 1);
        // 把字符串转换成整数
        int s1F = stringtoInt(s1First);
        int s2F = stringtoInt(s2First);
        int s1S = stringtoInt(s1Second);
        int s2S = stringtoInt(s2Second);
        // 整数部分
        int F = s1F * s2F - s1S * s2S;
        // 复数
        int S = s1F * s2S + s1S * s2F;
        cout << F << "+" << S << "i" << endl;
    }
    return 0;
}